<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/BasicTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Rewired Documentation | Unity Input Override</title>
<!-- InstanceEndEditable -->
<!-- InstanceParam name="isRoot" type="boolean" value="false" -->
<!-- InstanceParam name="wide" type="boolean" value="false" -->
<link href="files/css/styles.css" rel="stylesheet" type="text/css" />
<!-- Favicons -->
<link rel="icon" type="image/x-icon" href="/projects/rewired/files/images/favicon.ico?v=1" />
<!-- Apple Icons -->
<!-- For iPad with high-resolution Retina display running iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="files/images/favicon_152x152.png?v=1">
<!-- For iPad with high-resolution Retina display running iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="files/images/favicon_144x144.png?v=1">
<!-- For iPhone with high-resolution Retina display running iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="files/images/favicon_120x120.png?v=1">
<!-- For iPhone with high-resolution Retina display running iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="files/images/favicon_114x114.png?v=1">
<!-- For the iPad mini and the first- and second-generation iPad on iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="files/images/favicon_76x76.png?v=1">
<!-- For the iPad mini and the first- and second-generation iPad on iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="files/images/favicon_72x72.png?v=1">
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
<link rel="apple-touch-icon-precomposed" href="files/images/favicon_57x57.png?v=1">
</head>

<body>


<div class="container">

    <div class="google-search-bar">
        <script>
          (function() {
            var cx = '007961148920562332911:oocvtwz5jce';
            var gcse = document.createElement('script');
            gcse.type = 'text/javascript';
            gcse.async = true;
            gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
            var s = document.getElementsByTagName('script')[0];
            s.parentNode.insertBefore(gcse, s);
          })();
        </script>
        <gcse:search></gcse:search>
    </div>

  <div class="content">
	
	
	 
    <div class="page-body">
	
    
         
	    
      	<div class="sidebar-nav">
	        <h4><a href="Documentation.html">Documentation</a></h4>
	        <ul>
	          <li><a href="Overview.html">Overview</a></li>
	          <li><a href="ReleaseNotes.txt">Release Notes</a></li>
          </ul>
	        <strong>Essentials:</strong>
            <ol>
              <li><a href="Installation.html">Installation</a></li>
              <li><a href="QuickStart.html">Quick Start</a></li>
              <li><a href="BasicUsage.html">Basic Usage</a></li>
              <li><a href="Deployment.html">Deployment</a></li>
              <li><a href="BestPractices.html">Best Practices</a></li>
              <li><a href="RewiredEditor.html">Rewired Editor</a></li>
              <li><a href="https://guavaman.com/projects/rewired/docs/api-reference" target="_blank">API Reference</a></li>
            </ol>
            <strong>Concepts:</strong>
            <ul>
              <li><a href="InputManager.html">Input Manager</a></li>
              <li><a href="Players.html">Players</a></li>
              <li><a href="Actions.html">Actions</a></li>
              <li><a href="InputBehaviors.html">Input Behaviors</a></li>
              <li><a href="Controllers.html">Controllers</a></li>
              <li><a href="ControllerMaps.html">Controller Maps</a></li>
              <li><a href="ControllerTemplates.html">Controller Templates</a></li>
              <li><a href="MapCategories.html">Map Categories</a></li>
              <li><a href="Layouts.html">Layouts</a></li>
              <li><a href="LayoutManager.html">Layout Manager</a></li>
              <li><a href="MapEnabler.html">Map Enabler</a></li>
              <li><a href="CustomControllers.html">Custom Controllers</a></li>
            </ul>
            <strong>Extras:</strong>
            <ul>
              <li><a href="ControlMapper.html" title="Control Mapper">Control Mapper</a></li>
	          <li><a href="TouchControls.html" title="Touch Controls">Touch Controls</a></li>
              <li><a href="RewiredStandaloneInputModule.html">Rewired Standalone Input Module</a></li>
	          <li><a href="UnityInputOverride.html" title="Unity Input Override">Unity Input Override</a></li>
            </ul>
            <strong>Misc:</strong>
            <ul>
	          <li><a href="ComponentControls.html" title="Component Controls">Component Controls</a></li>
	          <li><a href="PlayerControllers.html" title="Player Controllers">Player Controllers</a></li>
	          <li><a href="InputMapper.html" title="Input Mapper">Input Mapper</a></li>
	          <li><a href="UserDataStore.html" title="User Data Store">User Data Store</a></li>
            </ul>
            <strong>How To's:</strong>
            <ul>
            	<li><a href="HowTos.html">See all topics...</a></li>
            </ul>
            <strong>Help:</strong>
            <ul>
              <li><a href="SupportedControllers.html" title="Supported Controllers">Supported Controllers</a></li>
              <li><a href="Overview.html#tested-platforms" title="Tested Platforms">Tested Platforms</a></li>
              <li><a href="Troubleshooting.html" title="Troubleshooting">Troubleshooting</a></li>
              <li><a href="KnownIssues.html">Known Issues</a></li>
              <li><a href="SpecialPlatformSupport.html" title="Special Platform Support">Special Platform Support</a></li>
	          <li><a href="Examples.html" title="Examples">Examples</a></li>
              <li><a href="Integration.html">Integrations</a></li>
	          <li><a href="Updating.html" title="Updating Rewired">Updating Rewired</a></li>
            </ul>
            <strong>FAQ</strong>
            <ul>
            	<li><a href="FAQ.html">See all topics...</a></li>
            </ul>
            <strong>Unity Help:</strong>
            <ul>
              <li><a href="https://docs.unity3d.com/Manual/" target="_blank">Unity Manual</a></li>
              <li><a href="https://docs.unity3d.com/ScriptReference/" target="_blank">Unity Script Reference</a></li>
              <li><a href="https://unity3d.com/learn/tutorials/modules" target="_blank">Unity Tutorials</a></li>
            </ul>
            <strong>Links:</strong>
            <ul>
              <li><a href="https://guavaman.com/projects/rewired">Rewired Website</a></li>
              <li><a href="https://guavaman.com/projects/rewired/docs">Web Documentation</a></li>
            </ul>
        </div>
        
    
    	<div class="main-body">
	        <div class="logo"><a href="https://guavaman.com/projects/rewired" title="Rewired"><img src="files/images/rewired-logo.png" width="173" height="139" alt="Rewired" /></a></div>
                     
            <h1>
            <!-- InstanceBeginEditable name="PageHeader" -->Unity Input Override
      <!-- InstanceEndEditable -->
            </h1>
            
			<!-- InstanceBeginEditable name="MainBody" -->

    <p>The Unity Input Override script  reroutes calls to Unity input from most scripts over to Rewired. Simply install it and every script that calls Input.GetButton, Input.GetAxis, etc. will now use Rewired instead of Unity input. This allows you to use Rewired for input without having to change any code in the scripts. This will even work for most assets downloaded from the Unity Asset Store, allowing you to use Rewired as the input source instead of Unity input.</p>
    <p><strong><a name="usage" id="usage"></a>Usage</strong></p>
    <ul>
      <li><a href="#installation">Install the Unity Input Override script</a>.</li>
      <li>Set up Actions in the <a href="RewiredEditor.html">Rewired Input Manager</a> with names equivalent to the Action names expected by your scripts.</li>
      <li>Create controller maps, Players, etc. using these Actions as per standard Rewired practice.</li>
    </ul>
    <p>Here is a simple example of a script that calls Input.GetButtonDown which will be rerouted to Rewired:</p>
<pre class="code"><span class="comment"></span>
using UnityEngine;
using System.Collections;

public class MyClass : MonoBehaviour {

    public void Update() {
<span class="comment">        // This call to Input.GetButtonDown will now go to Rewired instead</span>
        if(Input.GetButtonDown(&quot;Fire&quot;)) {
            <span class="comment">// shoot a bullet</span>
        }
    }
}</pre>
    Several global settings can be changed at runtime in UnityInputOverride:
<pre class="code">
<span class="comment">// Get or set the enabled state of the override.</span>
UnityInputOverride.enabled = false; <span class="comment">// if disabled, Input calls route to UnityEngine.Input</span>
UnityInputOverride.enabled = true; <span class="comment">// if enabled, Input calls route to Rewired</span>

<span class="comment">// Get or set the current Rewired Player</span>
UnityInputOverride.playerId = 2; <span class="comment">// change the Rewired Player Id so that input is retrieved from a different Rewired Player</span></pre>
    <p><strong><a name="how-it-works" id="how-it-works"></a>How it works</strong></p>
<p>Unity Input Override script takes advantage of the fact the compiler gives higher priority to classes in the global namespace when resolving references. Therefore, because the Unity Input Override class is named &quot;Input&quot; and is in the global namespace, it takes precendence over UnityEngine.Input. The compiler will now prefer Input (the Rewired class) over UnityEngine.Input when resolving references in scripts that make calls to Input.GetAxis, Input.GetButton, etc.</p>
    <p>The CS file is installed in the Plugins folder so it can be accessed by all C#, Unity Script, and Boo scripts.</p>
<p><strong><a name="limitations" id="limitations"></a>Limitations</strong></p>
    <p>There are some limitations to this system however.</p>
    <ol>
      <li>Does not work on Javascript or Boo scripts, only C# scripts.</li>
      <li>The input script must make all calls by using the shortened form of &quot;Input.GetAxis&quot; instead of the fully-qualified form &quot;UnityEngine.Input.GetAxis&quot;. Scripts that use fully-qualified calls cannot be rerouted to Rewired because the compiler is explicitly instructed which Input class to use.</li>
      <li>Calls to Unity input from within DLL's cannot be rerouted.</li>
      <li>Calls to Input.GetKey or Input.GetKeyDown will not benefit from Rewired's Action-based system.</li>
      </ol>
    <p><strong><a name="notes" id="notes"></a>Notes</strong></p>
    <ul>
      <li>Mouse Sensitivity: If the script you are using processes Mouse X/Y axis values such as a mouse-look script, be sure to <a href="RewiredEditor.html#InputBehaviors">set the Mouse XY Axis Sensitivity in the Input Behavior</a> assigned to the Actions to 0.1 instead of Rewired's default value of 1. Unity defaults to 0.1 sensitivity for mouse axes, so you should change this value to match if you want the scripts to behave the same way they would when using Unity input.</li>
      <li><a name="location-service" id="location-service"></a>UnityEngine.Input contains the property &quot;location&quot; which returns a LocationService object. Because UnityInputOverride mirrors all properties and methods of UnityEngine.Input, it includes a property for location. The catch is, the mere presence of this code even when there are zero actual calls to it causes Unity to automatically add the Location permission requirement to your application on some platforms (Android is known to do this at present.) If your game does not need the Location permission, this line of code must be removed from UnityInputOverride. You can disable support by  by setting &quot;Disable UnityInputOverride LocationService Support&quot; in the Rewired Global Options window which can be found at:  Window -&gt; Rewired -&gt; Global Options. Note that this option applies to the current build target group that is selected in the Unity Build Settings window. To set this option for multiple build targets, you must set it for each by selecting the build target group, then setting the option.</li>
    </ul>
    <p><strong><a name="installation" id="installation"></a>Installation</strong></p>
    <p>Install the script from the menu:</p>
    <ul>
      <li>Window -&gt; Rewired -&gt; Extras -&gt; Unity Input Override -&gt; Install</li>
    </ul>
<p>This will install one file in the following location:</p>
    <ul>
      <li>Plugins/Rewired/UnityInputOverride.cs file </li>
    </ul>
<p><strong><a name="uninstallation" id="uninstallation"></a>Uninstallation</strong></p>
<p>Delete the Plugins/Rewired/UnityInputOverride.cs file.</p>
    <p>Or you can disable the script for the current platform by adding REWIRED_DISABLE_UNITY_INPUT_OVERRIDE to the <a href="https://docs.unity3d.com/Manual/PlatformDependentCompilation.html" target="_blank">custom Scripting Define Symbols in the Unity Player settings</a>.</p>
    <div class="bottom-pager clearfix">
      <a class="back-button" href="Documentation.html" title="Actions"><span class="button-img"></span>Documentation</a></div>
<!-- InstanceEndEditable -->
        </div>
        
    </div>
  <div class="footer clearfix">
   	<p class="left">Copyright &copy;2014-2021 <a href="https://guavaman.com" title="Guavaman Enterprises">Guavaman Enterprises</a>. All rights reserved. No materials may be reproduced without permission.</p>
  	<p class="right"><a href="https://guavaman.com/projects/rewired" title="Return to Rewired Website">Return to Rewired Website</a></p>
  </div>
  <!-- end .content --></div>
  <!-- end .container --></div>
  
  
</body>
<!-- InstanceEnd --></html>
